<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>找回密码</title>
    <link rel="stylesheet" href="__MEMBER__/css/base.css" type="text/css">
    <link rel="stylesheet" href="__MEMBER__/css/global.css" type="text/css">
    <link rel="stylesheet" href="__MEMBER__/css/register.css" type="text/css">
    <link rel="stylesheet" href="__MEMBER__/css/footer.css" type="text/css">
    <!--[if lt IE 9]-->
    <script type="text/javascript" src="__PUBLIC__/jquery-1.10.2.min.js"></script>
    <!--[endif]-->
    <script type="text/javascript" src="__PUBLIC__/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/assets/plugins/layer-v2.0/layer/layer.js"></script>
  </head>
<body>
<div class="top_wrapper pt20"  style="background: url(/Public/assets/img/header_bg.png) repeat-x;width: 100%;height: 160px;color: #fff;">
	<div class="w990 bc header">
        <div id="logo"><h1 class="fl"><a href="/"><img width="180" height="50" alt="CHP" src="__PUBLIC__/logo.png"></a></h1><span class="fl">欢迎来到找回密码</span></div>
	</div>

</div>

<div class="center_wrapper pb100">
	<div class="w990 bc">
		<div class="reg-form mt20">
		  <form name="reg_form" method="post" action="">
		    	<div id="form-item-account" class="form-item form-item-account">
		            <label>手&#12288;机&#12288;号</label>
					<input type="text" placeholder="请输入手机号" maxlength="20" id="mobile" autocomplete="off" class="field" name="mobile">
		        </div>
		        <div class="input-tip"></div>
		        <div class="form-item form-item-account">
		            <label>财务编号</label>
					<input type="text" placeholder="请输入财务编号" maxlength="50" id="financial_code" autocomplete="off" class="field" name="financial_code">
		        </div>
				<div class="input-tip"></div> 
				<div class="form-item form-item-phonecode">
		            <label>手机验证码</label>
		            <input type="text" placeholder="请输入手机验证码" class="field phonecode" maxlength="6" name="mobilecode" id="mobilecode">
		            <button type="button" class="btn-phonecode">获取验证码</button>
		        </div>
				<div class="input-tip"></div>
				<div>
					<input class="btn-register" onclick="coldchack()" value="下一步" type="button"> 
				</div>
		   </form>
	    </div>
	</div>
</div>
<div class="main-footer" style="border:0px solid red">
    <div>
        {:C('WEB_SITE_ICP')}
    </div>
</div>
	<script type="text/javascript" src="__PUBLIC__/jquery.validate.min.js"></script>
	<script type="text/javascript">
		//60秒短信计时
		var outTime = 60;  
		function remainMessage(){  
		    if(outTime==0){  
		        outTime=60;
		        $('.btn-phonecode').html('获取验证码');
		      	//绑定发送短信的事件
				$(".btn-phonecode").click(function(){
					findphono();
				})
		        return;
		    }
		    $('.btn-phonecode').html((outTime--)+'秒后重新发送');
		    setTimeout("remainMessage()",1000);  
		}
		$(function(){		
			$(".btn-phonecode").click(function(){
				findphono();
			})
			$("form[name=reg_form]").validate({
				errorElement : "span",
				errorPlacement: function(error, element) {
				    error.appendTo( element.parent().next());
				},
				rules: {
					mobile: {
						required: true,
						rangelength:[11,11]
					},
					password : {
						required : true,
						rangelength:[6,20]
					},
					cpassword : {
						required : true,
						equalTo : '#password'
					},
					chkcode :{
						required : true,
						minlength : 4,
					},
					mobilecode :{
						required : true,
						minlength : 4,
					},
					allow_protocol : {
						required : true
					}

				},
				messages : {
					mobile : {
						required : '*请输入手机号码',
						rangelength : '*请输入11位手机号码',
					},
					mobilecode : {
						required : '*请输入手机验证码',
						minlength : '*请输入4位手机验证码'
					}
				}
			})

	
		})
		
		 function findphono(){
			var mobile = $("#mobile").val();
				$.ajax({
				url : "{:U('Member/Public/findMobile','','')}/mobile/"+mobile,
		 		type : "get",
		 		dataType : "json",
		 		success : function(data){
		  			if(!data.status){
		  				layer.msg(data.info, {
											  icon: 2,
											  time: 2000 //2秒关闭（如果不配置，默认是3秒）
											});
		  			}else{
		  				layer.msg(data.info, {
											  icon: 1,
											  time: 2000 //2秒关闭（如果不配置，默认是3秒）

											},function(){
												remainMessage();
		 			                        	//解除发送短信的事件
		 				                        $(".btn-phonecode").unbind("click");
											});   

		  			}
		 		}
			 })
			

		}
		//验证验证码
		function coldchack(){
			var mobilecode = $("#mobilecode").val();
			var mobile = $("#mobile").val();
			var financial_code = $("#financial_code").val();
				$.ajax({
				url : "{:U('Member/Public/getForgetPassword','','')}/mobile/"+mobile+"/mobilecode/"+mobilecode+"/financial_code/"+financial_code,
		 		type : "get",
		 		dataType : "json",
		 		success : function(data){
		  			if(!data.status){
		  				layer.msg(data.info, {
						  icon: 2,
						  time: 2000 
						});
		  			}else{
		  			 	window.location.href=data.url; 
		  			}
		 		}
			 })
			

		}
	</script>
    </body>
</html>